/**
 * 数字看板的所有类型
 */
import { widgetApi } from '../../services/analysis';

function toPercent(data) {
	return `${Math.round((data || 0) * 100)}%`;
}

const types = [
	{
		itemId: 1, // 即将废弃，靠uri来对应
		type: 'device', // 区分几个分析页面所使用的看板
		name: '累计设备总数',
		url: '/deviceAnalysis', // 点击跳转地址
		needQueryKeys: ['productId'],
		uri: widgetApi.totalDeviceCount // 接口地址
	},
	{
		itemId: 4,
		type: 'device',
		name: '新增设备台数',
		needQueryKeys: ['productId'],
		uri: widgetApi.newDeviceCount,
		url: '/deviceAnalysis'
	},
	{
		itemId: 33,
		type: 'device',
		name: '设备在线率(%)',
		dataKey: toPercent,
		url: '/deviceAnalysis',
		needQueryKeys: ['productId'],
		uri: widgetApi.onlineDevicePercent
	},
	{
		itemId: 2,
		type: 'device',
		name: '昨日新增设备数(台)',
		url: '/deviceAnalysis',
		needQueryKeys: ['productId'],
		uri: widgetApi.yesterNewDeviceCount
	},
	{
		itemId: 34,
		type: 'device',
		name: '设备活跃率(%)',
		dataKey: toPercent,
		uri: widgetApi.activateDevicePercent,
		needQueryKeys: ['productId'],
		url: '/deviceAnalysis',
	},
	{
		itemId: 42,
		icon: 'device',
		name: '租赁设备台数',
		needQueryKeys: ['productId'],
		url: '/deviceAnalysis',
		uri: widgetApi.leaseDeviceCount,
	},
	// {
	// 	itemId: 3,
	// 	type: 'device',
	// 	name: '今日设备订单率',
	// 	dataKey: d => `${Math.round((d.orderedPercent || 0) * 100)}%`,
	// 	query: getDeviceBoard
	// },
	// {
	// 	itemId: 3,
	// 	icon: 'device',
	// 	name: '故障设备台数',
	// 	needQueryKeys: ['productId'],
	// 	uri: widgetApi.faultDeviceCount
	// },
	// {
	// 	itemId: 4,
	// 	type: 'device',
	// 	name: '当前设备故障数',
	// 	query: getDeviceBoard,
	// },
	// {
	// 	itemId: 100,
	// 	type: 'device',
	// 	name: '今日新激活设备数',
	// 	query: getDeviceBoard,
	// },


	{
		itemId: 5,
		type: 'user',
		name: '累计用户总数',
		uri: widgetApi.userTotalCount,
		url: '/userAnalysis'
	},
	// {
	// 	itemId: 6,
	// 	type: 'user',
	// 	name: '昨日用户增长率',
	// 	dataKey: d => `${Math.round((d.newPercent || 0) * 100)}%`,
	// 	query: getUserBoard
	// },
	{
		itemId: 36,
		type: 'user',
		name: '新增用户人数',
		url: '/userAnalysis',
		uri: widgetApi.userNewCount
	},
	{
		itemId: 40,
		icon: 'user',
		name: '新增租赁人数',
		url: '/userAnalysis',
		uri: widgetApi.userNewOrderedCount
	},
	{
		itemId: 41,
		icon: 'user',
		name: '累计租赁人数',
		url: '/userAnalysis',
		uri: widgetApi.userOrderedCount
	},
	{
		itemId: 7,
		type: 'user',
		name: '昨日活跃用户数',
		url: '/userAnalysis',
		uri: widgetApi.userActiveCount
	},
	{
		itemId: 8,
		type: 'user',
		name: '昨日用户活跃率',
		dataKey: toPercent,
		url: '/userAnalysis',
		uri: widgetApi.userActivePercent
	},
	{
		itemId: 9,
		type: 'order',
		name: '新增订单数',
		needQueryKeys: ['productId'],
		uri: widgetApi.newOrderCount,
		url: '/orderAnalysis'
	},
	{
		itemId: 10,
		type: 'order',
		name: '本月订单数',
		needQueryKeys: ['productId'],
		url: '/orderAnalysis',
		uri: widgetApi.monthOrderCount
	},
	{
		itemId: 11,
		type: 'order',
		name: '订单完成数',
		needQueryKeys: ['productId'],
		url: '/orderAnalysis',
		uri: widgetApi.finishOrderCount
	},
	{
		itemId: 12,
		type: 'order',
		name: '累计订单总数',
		needQueryKeys: ['productId'],
		url: '/orderAnalysis',
		uri: widgetApi.totalOrderCount
	},
	{
		itemId: 14,
		type: 'alarm',
		name: '今日新增告警记录',
		needQueryKeys: ['productId'],
		url: '/alarmAnalysis',
		uri: widgetApi.newAlarmCount
	},
	{
		itemId: 15,
		type: 'alarm',
		name: '设备告警率',
		dataKey: toPercent,
		needQueryKeys: ['productId'],
		url: '/alarmAnalysis',
		uri: widgetApi.deviceAlarmPercent
	},

	{
		itemId: 31,
		type: 'share',
		name: '今日分润账单数',
		needQueryKeys: ['productId'],
		uri: widgetApi.benefitBillCount
	},
	{
		itemId: 32,
		type: 'share',
		name: '今日分润金额',
		needQueryKeys: ['productId'],
		uri: widgetApi.benefitMoney
	},
	/**
	 * 告警分析
	 */
	{
		itemId: 411123, // 不知道还有没有
		type: 'fault',
		name: '设备故障数',
		needQueryKeys: ['productId'],
		url: '/alarmAnalysis',
		uri: widgetApi.faultDeviceCount
	},
	{
		itemId: 42,
		type: 'fault',
		name: '设备故障率',
		dataKey: toPercent,
		needQueryKeys: ['productId'],
		url: '/alarmAnalysis',
		uri: widgetApi.deviceFalutPercent
	},
	{
		itemId: 43,
		type: 'fault',
		name: '设备报警数',
		url: '/alarmAnalysis',
		uri: widgetApi.deviceAlarmCount
	},
	{
		itemId: 13,
		type: 'fault',
		name: '当前告警设备数',
		uri: widgetApi.alarmDeviceCount,
		needQueryKeys: ['productId'],
		url: '/alarmAnalysis'
	},
	{
		itemId: 42,
		type: 'fault',
		name: '设备报警率',
		dataKey: toPercent,
		needQueryKeys: ['productId'],
		url: '/alarmList',
		uri: widgetApi.deviceAlarmPercent
	},
];

export default types;
